Developer Documentation
PATH  Mac OS X Documentation > Cocoa > Application Design for Scripting, Documents, and Undo


Previous | Chapter contents | Next | Book PDF

Object Specifiers

Object specifiers use key-value coding to evaluate the underlying objects they represent. Object specifiers in AppleScript are expressions such as "words whose color is red of the fourth paragraph of the front document of application `TextEdit'". Object specifiers in Yellow Box applications are objects of the NSObjectSpecifier class. Concrete subclasses of this abstract class represent the different reference forms supported by AppleScript, such as index references ("word 5") and filter references (tests or "whose" clauses).

NSObjectSpecifiers are nested, so the example in the preceding paragraph would actually be represented by a chain of three references: one for the words, one for the paragraph, one for the document. (The "application `TextEdit'" part does not need representation since the specifier exists in TextEdit by the time the command is executed.) NSObjectSpecifiers know how to evaluate themselves within their containing specifier. The explicit top-level specifier ("front document" in the example) evaluates itself within a default top-level container, which is usually the application itself.

Usually you don't have to worry about specifiers when you make an application scriptable. However, it helps to understand them if you wish to support recordability in your application, which requires you to create them.


Application Design for Scripting, Documents, and Undo

Previous | Chapter contents | Next | Book PDF